home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_c / cuj0696.zip / DWYER.ZIP / FREQ.TST / SETKOSM.C < prev    next >
C/C++ Source or Header  |  1996-01-08  |  2KB  |  72 lines

  1. /* ============ */
  2. /* setkosm.c    */
  3. /* ============ */
  4. #include <io.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <math.h>
  8. #include <mconf.h>
  9. #include <miscdefs.h>
  10. #include <freqdefs.h>
  11.  
  12. #define    ACT(X)    #X
  13.  
  14. #define    CLAMP(Out, Var, Lo, Hi)    Out = __min(Hi, __max(Lo, Var))
  15.  
  16. #define    NEED_ALL(Label)    "\nEnter Number of "Label
  17.  
  18. #define    NEED_USER_ENTRY(LABEL, LO, HI) \
  19.     NEED_ALL(LABEL" ["ACT(LO)"-"ACT(HI)"]: ")
  20.  
  21. #define    SAMPLES_LABEL    "Samples Per K-S Run"
  22. #define    KS_RUNS_LABEL    "K-S Runs For KS-on-KS Calculation"
  23.  
  24. #define    REPORT_USER_INT_ENTRY(Entry, Label)        \
  25.     {                            \
  26.     fflush(NULL); printf("\n");            \
  27.     printf("\tNumber Entered:  %.f", (double)Entry);\
  28.     printf(" (%s)\n", Label);            \
  29.     }
  30. #define    SHOW_INT_VALUE_USED(Entered, Used)             \
  31.     printf("\tTest Value Used: %.f%s\n", (double)Used,    \
  32.     ((double)Entered == (double)Used) ? "" : " (Clamped)")
  33.  
  34. /* ==================================================================== */
  35. /* SetKoSmControls - Sets Run Controls for Kolmogorov-Smirnov test    */
  36. /* ==================================================================== */
  37. void
  38. SetKoSmControls(KS_DATA_STRU *KSData)
  39. {
  40.     int     NewlineCh;
  41.     int     UserIntEntry;
  42.  
  43.     NewlineCh = _isatty(_fileno(stdin)) ? '\r' : '\n';
  44.  
  45.     fflush(NULL);fprintf(stderr, "%c", NewlineCh);
  46.     /* --------------------------------- */
  47.     /* Get Number of Samples Per K-S Run */
  48.     /* --------------------------------- */
  49.     fflush(NULL);
  50.     GetInt(NEED_USER_ENTRY(SAMPLES_LABEL, MIN_KS_SAMPS, MAX_KS_SAMPS),
  51.     &UserIntEntry);
  52.  
  53.     REPORT_USER_INT_ENTRY(UserIntEntry, SAMPLES_LABEL);
  54.  
  55.     CLAMP(KSData->SampleSize, UserIntEntry, MIN_KS_SAMPS, MAX_KS_SAMPS);
  56.  
  57.     SHOW_INT_VALUE_USED(UserIntEntry, KSData->SampleSize);
  58.  
  59.     /* ------------------------------------------- */
  60.     /* Get Number of KS Runs for KS-on-KS Analysis */
  61.     /* ------------------------------------------- */
  62.     fflush(NULL);fprintf(stderr, "%c", NewlineCh);
  63.     GetInt(NEED_USER_ENTRY(KS_RUNS_LABEL, MIN_KS_RUNS, MAX_KS_RUNS),
  64.     &UserIntEntry);
  65.  
  66.     REPORT_USER_INT_ENTRY(UserIntEntry, KS_RUNS_LABEL);
  67.  
  68.     CLAMP(KSData->NumKSRuns, UserIntEntry, MIN_KS_RUNS, MAX_KS_RUNS);
  69.  
  70.     SHOW_INT_VALUE_USED(UserIntEntry, KSData->NumKSRuns);
  71. }
  72.